package com.zg.common.lock.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;
import java.io.StringReader;

/**
 * <p>Description: </p>
 *
 * @author zhanfeng.liang
 * @since 2025/5/20 18:34
 */

@Configuration
public class RedissonConfig {

    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient(@Value("${redisson.config}") String configText) throws IOException {
        Config config = Config.fromYAML(new StringReader(configText));
        return Redisson.create(config);
    }
}
